![]() |
SetThreadScheduler |
||||
Header: | Threads.h | Carbon status: | Supported | |
Installs a custom scheduling function (custom scheduler).
OSErr SetThreadScheduler ( ThreadSchedulerTPP threadScheduler );
A pointer to a custom scheduler. Specify NULL if you want to remove an installed custom scheduler and use the default Thread Manager scheduling mechanism.
A result code. Δ
The SetThreadScheduler function installs a custom scheduler that runs in conjunction with the default Thread Manager scheduling mechanism. The Thread Manager uses a scheduler information structure to pass the custom scheduler the ID of the current thread and the ID of the thread that the Thread Manager has scheduled to run next.
A custom scheduler should return to the Thread Manager the ID of the thread that it determines to schedule. If it does not determine a particular thread to schedule, it should return the constant kNoThreadID and the Thread Manager default scheduling mechanism schedules the next thread.
If you already have a custom scheduler installed when you call SetThreadScheduler, it replaces the old one with a new one. If you want to remove your custom scheduler and return to using the default Thread Manager scheduling mechanism, call SetThreadScheduler and specify a value of NULL for the parameter.
The SetThreadScheduler function automatically disables scheduling to avoid any reentrancy problems with the custom scheduling function. Therefore, in your custom scheduling function, you should make no yield calls or other calls that would cause scheduling to occur.
Do not pass a function descriptor as the threadScheduler parameter to the SetThreadScheduler function. As with all Thread Manager functions that pass a function pointer, you must pass the address of the function, not the address of a function descriptor. You are required to use function descriptors when you write code in the PowerPC instruction set that passes a function’s address to code that might be in the 680x0 instruction set. However, the threads in your application must all be in the same instruction set—680x0 or PowerPC. Therefore, the function identified by the threadScheduler parameter is by definition in the same instruction set as the SetThreadScheduler function and a function descriptor is not required.
For more information on the custom scheduling function, see the ThreadSchedulerProcPtr function.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)